<template>
  <div class="mission-item" @click="goDetail(missionObj)">
    <img :src="missionObj.imageUrl[0]" alt=""/>
    <p class="info-box price">
      <span>¥{{ missionObj.reward / 100 }}</span>
      <span v-if="missionObj.urgent">{{ $t('加急') }}</span>
    </p>
    <p class="info-box title">
      {{ missionObj.title }}
    </p>
    <p class="info-box summary">{{ missionObj.description }}</p>
    <div class="info-box">
      <div class="tag">
        <span>{{
          missionObj.sex == 1
            ? $t('男')
            : missionObj.sex == 2
            ? $t('女')
            : $t('未知')
        }}</span>
        <span>{{ calculateAge(missionObj.birthday) }}</span>
        <span>{{ missionObj.height }}cm</span>
        <span>{{ missionObj.weight }}kg</span>
      </div>
      <div class="address">
        <i class="el-icon-location"></i>
        <span>{{ calcAddress(missionObj.detailAddress) }}</span>
      </div>
    </div>
  </div>
</template>
<script>
import { calculateAge } from '@/utils/index.js'
export default {
  props: {
    missionObj: {},
  },
  methods: {
    goDetail(item) {
      // if (window.getSelection().toString().length > 0) return
      this.$router.push({ name: 'MissionDetail', query: { id: item.id } })
    },
    calculateAge(time) {
      return calculateAge(time)
    },
    calcAddress(addr) {
      let i = addr ? addr.indexOf(' ') : -1
      if (i == 0 || i == -1) {
        return this.$t('未知')
      } else {
        return addr.slice(0, i)
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.mission-item {
  width: 13.22rem;
  border: 0.06rem solid #dcdfe6;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: 0.3rem;
  overflow: hidden;
  cursor: pointer;
  img {
    height: 6.14rem;
    width: 100%;
    border-radius: 0.3rem;
    object-fit:contain;
  }
  .info-box {
    padding: 0 0.44rem;
    display: flex;
    justify-content: space-between;
  }
  .price {
    margin-bottom: 0.39rem;
    span:nth-child(1) {
      color: #f85c02;
      font-size: 0.89rem;
      font-weight: bold;
      line-height: 1.22rem;
      letter-spacing: 1px;
    }
    span:nth-child(2) {
      font-size: 0.67rem;
      background: #f85c02;
      line-height: 1.22rem;
      color: #fff;
      padding: 0 0.22rem;
    }
  }
  .title {
    font-weight: bold;
    font-size: 0.78rem;
    color: #333333;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .summary {
    font-weight: 400;
    font-size: 0.78rem;
    color: #999999;
    line-height: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0.22rem 0 0.89rem 0;
    height: 2rem;
  }
  .tag {
    margin-bottom: 0.83rem;
    span {
      line-height: 1.11rem;
      font-size: 0.67rem;
      color: #339eff;
      border: 0.06rem solid #339eff;
      padding: 0 0.22rem;
      margin-right: 0.22rem;
    }
  }
  .address {
    i {
      color: #4d4d4d;
      font-size: 0.78rem;
      margin-right: 0.22rem;
    }
    span {
      color: #333333;
      font-size: 0.78rem;
    }
  }
}
</style>
